import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet(urlPatterns = {"/login/dgout"})
public class LogoutServlet extends HttpServlet{
    protected void doPost(HttpServletRequest req,
                         HttpServletResponse resp) throws IOException {
       if((req.getSession().getAttribute("userDTO"))!=null){
           req.getSession().removeAttribute("userDTO");
        }
       if((req.getSession().getAttribute("localdataDTO"))!=null){
           req.getSession().removeAttribute("localdataDTO");
       }
        resp.sendRedirect("https://cas.dgut.edu.cn/logout?callback=http://localhost:8080/Login.jsp");
    }
    protected  void  doGet(HttpServletRequest req,
                           HttpServletResponse resp) throws IOException{
        doPost(req,resp);
    }
}
